<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>销量页面</title>
    <link rel="stylesheet" href="../../static/css/bootstrap.min.css">
    <script src="../../static/js/axios-0.18.0.js"></script>
    <script src="../../static/js/vue.js"></script>
    <script src="../../static/plugins/echarts/echarts.js"></script>
    <!--引入样式-->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input @keyup.enter.native="findPage()" placeholder="订单号/商品名称" v-model="pagination.queryString" style="width: 200px;" class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <template>
                    <h4 class="el-icon-help">选择商品类型</h4>
                    <el-select placeholder="全部" v-model="findstatus" @change="findPage()">
                        <el-option key="1" label="全部" value=""></el-option>
                        <el-option key="2" label="数码" value="数码"></el-option>
                        <el-option key="3" label="书籍" value="书籍"></el-option>
                        <el-option key="4" label="生活用品" value="生活用品"></el-option>
                        <el-option key="5" label="服装" value="服装"></el-option>
                        <el-option key="6" label="美妆" value="美妆"></el-option>
                        <el-option key="7" label="旅游" value="旅游"></el-option>
                        <el-option key="8" label="其他" value="其他"></el-option>
                    </el-select>
                </template>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="id" label="订单编号" align="center"></el-table-column>
                <el-table-column prop="commname" label="商品名" align="center"></el-table-column>
                <el-table-column prop="commdesc" label="商品描述" align="center">
                    <template slot-scope="scope">
                        <el-tooltip class="item" effect="light" :content="scope.row.commdesc" placement="top-start" style="width: 400px">
                            <span>{{scope.row.commdesc.substring(0,16)}}...</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column prop="soldmoney" label="售价" align="center"></el-table-column>
                <el-table-column prop="soldtime" label="售出时间" align="center"></el-table-column>
                <el-table-column label="操作"  align="center" width="200px">
                    <template slot-scope="scope">
                        <el-button-group>
                            <el-button type="primary" size="mini" @click="handleDetail(scope.row)">详情</el-button>
                        </el-button-group>
                    </template>
                </el-table-column>
            </el-table>
            <!--分页-->
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            findstatus:'',
            pagination:{
                currentPage:0,
                pageSize:10,
                queryString:'',
                total:0
            },
            dataList:[{
                id:'1234546',
                commname:'黎朝权',
                commdesc:'dfhadfhoajsdfojasf',
                soldmoney:1235,
                soldtime:'2021.03.29'
            }],

        },
        created(){
            this.findPage();
        },
        methods:{
            //查询
            findPage(){
                var page = {
                    currentPage : this.pagination.currentPage,
                    pageSize : this.pagination.pageSize,
                    queryString : this.pagination.queryString
                }
                axios.post("/sold/findall?findString="+this.findstatus,page).then((res)=>{
                        //插叙能成功
                        this.dataList = res.data.rows;
                        this.pagination.total = res.data.total;
                }).catch(()=>{
                    this.$message.error("查询错误");
                })
            },
            //查看详情
            handleDetail(row){
                window.open("/sold/solddetail/"+row.commid,"_blank")
            },
            handleCurrentChange(){
                this.findPage();
            }
        }
    })
</script>
</html>